package com.sxbbc.common.basics.service.solr.entity;

import java.util.List;
import java.util.Map;

import org.apache.solr.common.SolrDocumentList;

import com.fasterxml.jackson.databind.ser.std.SerializableSerializer;

public class Solrpage<T> extends SerializableSerializer {


    private static final long serialVersionUID = -4393659509622109020L;
    /**
     * 对象集合
     */
    private List<T> list;
    /**
     * 当前页
     */
    private int cpage = 1;
    /**
     * 每页条数
     */
    private int pageSize = 20;
    /**
     * 总条数
     */
    private long totalrows = 0;
    /**
     * 总页数
     */
    private long totalpages = 1;
    /**
     * solr返回集合
     */
    private SolrDocumentList results;
    /**
     * 返回高亮对象
     */
    private Map<String, Map<String, List<String>>> highlighting;

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getCpage() {
        return cpage;
    }

    public void setCpage(int cpage) {
        this.cpage = cpage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotalrows() {
        return totalrows;
    }

    public void setTotalrows(long totalrows) {
        this.totalrows = totalrows;
    }

    public long getTotalpages() {
        if (totalrows <= pageSize) {
            totalpages = 1;
        } else {
            if (totalrows % pageSize == 0) {
                totalpages = totalrows / pageSize;
            } else {
                totalpages = totalrows / pageSize + 1;
            }
        }
        return totalpages;
    }

    public SolrDocumentList getResults() {
        return results;
    }

    public void setResults(SolrDocumentList results) {
        this.results = results;
    }

    public Map<String, Map<String, List<String>>> getHighlighting() {
        return highlighting;
    }

    public void setHighlighting(Map<String, Map<String, List<String>>> highlighting) {
        this.highlighting = highlighting;
    }


}
